<template>
  <div class="mainContact">
    <div v-for="item in this.$store.getters.getContacts" :key="item.id">
      <main-contact-item :contact="item"></main-contact-item>
    </div>
  </div>
</template>

<script>
import * as ActionsTypes from '@/store/actions-types';
import MainContactItem from './main.contact.item';

export default {
  name: 'mainContact',
  data() {
    return {
    };
  },
  created() {
    console.log('1--->', this.$store.getters.getContacts);
    console.log('3--->', !this.$store.getters.getContacts);
    if (!this.$store.getters.getContacts) {
      const params = {
        clientId: 'e2b6abfc-3576-4fe7-9f69-1f647169a827',
        clientSecret: 'e24e45c9-a7bc-4248-be78-17b32bea1544',
      };
      this.$store.dispatch(ActionsTypes.fetchContacts, params);
    }
  },
  components: {
    props: {
      contact: { },
    },
    'main-contact-item': MainContactItem,
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
  font-weight: normal;
}

ul {
  list-style-type: none;
  padding: 0;
}

li {
  display: inline-block;
  margin: 0 10px;
}

a {
  color: #42b983;
}
</style>
